package easy.trace.core.util;

/**
 * @author easy
 */
public class StringUtils {

    public static int countOccurrencesOfPoint(String str) {
        return countOccurrencesOf(str, ".");
    }

    public static int countOccurrencesOf(String str, String token) {
        if (str == null || token == null || str.length() == 0 || token.length() == 0) {
            return 0;
        }
        int count = 0;
        int pos = 0;
        int idx;
        while ((idx = str.indexOf(token, pos)) != -1) {
            ++count;
            pos = idx + token.length();
        }
        return count;
    }

    public static boolean isEmpty(final CharSequence cs) {
        return cs == null || cs.length() == 0;
    }

    public static boolean nonEmpty(final CharSequence cs) {
        return !isEmpty(cs);
    }

}
